
<h1><span class="yiyi-st" id="yiyi-12">numpy.split</span></h1>
        <blockquote>
        <p>原文：<a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.split.html">https://docs.scipy.org/doc/numpy/reference/generated/numpy.split.html</a></p>
        <p>译者：<a href="https://github.com/wizardforcel">飞龙</a> <a href="http://usyiyi.cn/">UsyiyiCN</a></p>
        <p>校对：（虚位以待）</p>
        </blockquote>
    
<dl class="function">
<dt id="numpy.split"><span class="yiyi-st" id="yiyi-13"> <code class="descclassname">numpy.</code><code class="descname">split</code><span class="sig-paren">(</span><em>ary</em>, <em>indices_or_sections</em>, <em>axis=0</em><span class="sig-paren">)</span><a class="reference external" href="http://github.com/numpy/numpy/blob/v1.11.3/numpy/lib/shape_base.py#L427-L502"><span class="viewcode-link">[source]</span></a></span></dt>
<dd><p><span class="yiyi-st" id="yiyi-14">将数组拆分为多个子数组。</span></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name">
<col class="field-body">
<tbody valign="top">
<tr class="field-odd field"><th class="field-name"><span class="yiyi-st" id="yiyi-15">参数：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-16"><strong>ary</strong>：ndarray</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-17">数组被分为子数组。</span></p>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-18"><strong>indices_or_sections</strong>：int或1-D数组</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-19">如果<em class="xref py py-obj">indices_or_sections</em>是整数N，则数组将沿<em class="xref py py-obj">轴</em>划分为N等于数组。</span><span class="yiyi-st" id="yiyi-20">如果这样的分割是不可能的，则引起错误。</span></p>
<p><span class="yiyi-st" id="yiyi-21">如果<em class="xref py py-obj">indices_or_sections</em>是排序整数的1-D数组，则条目指示数组沿着<em class="xref py py-obj">轴</em>的位置。</span><span class="yiyi-st" id="yiyi-22">例如，对于<code class="docutils literal"><span class="pre">axis=0</span></code>，<code class="docutils literal"><span class="pre">[2，</span> <span class="pre">3]</span></code></span></p>
<blockquote>
<div><ul class="simple">
<li><span class="yiyi-st" id="yiyi-23">ary [：2]</span></li>
<li><span class="yiyi-st" id="yiyi-24">ary [2：3]</span></li>
<li><span class="yiyi-st" id="yiyi-25">ary [3：]</span></li>
</ul>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-26">如果索引超过沿<em class="xref py py-obj">轴</em>的数组的大小，则相应返回空子阵列。</span></p>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-27"><strong>axis</strong>：int，可选</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-28">要拆分的轴，默认值为0。</span></p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name"><span class="yiyi-st" id="yiyi-29">返回：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-30"><strong>子数组</strong>：ndarrays列表</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-31">子数组列表。</span></p>
</div></blockquote>
</td>
</tr>
<tr class="field-odd field"><th class="field-name"><span class="yiyi-st" id="yiyi-32">上升：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-33"><strong>ValueError</strong></span></p>
<blockquote class="last">
<div><p><span class="yiyi-st" id="yiyi-34">如果<em class="xref py py-obj">indices_or_sections</em>作为整数给出，但是拆分不会导致相等的除法。</span></p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title"><span class="yiyi-st" id="yiyi-35">也可以看看</span></p>
<dl class="last docutils">
<dt><span class="yiyi-st" id="yiyi-36"><a class="reference internal" href="numpy.array_split.html#numpy.array_split" title="numpy.array_split"><code class="xref py py-obj docutils literal"><span class="pre">array_split</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-37">将数组拆分成等于或接近相等大小的多个子数组。</span><span class="yiyi-st" id="yiyi-38">如果不能进行等分，则不会引发异常。</span></dd>
<dt><span class="yiyi-st" id="yiyi-39"><a class="reference internal" href="numpy.hsplit.html#numpy.hsplit" title="numpy.hsplit"><code class="xref py py-obj docutils literal"><span class="pre">hsplit</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-40">水平（逐列）将数组拆分成多个子数组。</span></dd>
<dt><span class="yiyi-st" id="yiyi-41"><a class="reference internal" href="numpy.vsplit.html#numpy.vsplit" title="numpy.vsplit"><code class="xref py py-obj docutils literal"><span class="pre">vsplit</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-42">垂直（逐行）将数组拆分成多个子数组。</span></dd>
<dt><span class="yiyi-st" id="yiyi-43"><a class="reference internal" href="numpy.dsplit.html#numpy.dsplit" title="numpy.dsplit"><code class="xref py py-obj docutils literal"><span class="pre">dsplit</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-44">将数组沿着第3轴（深度）拆分成多个子数组。</span></dd>
<dt><span class="yiyi-st" id="yiyi-45"><a class="reference internal" href="numpy.concatenate.html#numpy.concatenate" title="numpy.concatenate"><code class="xref py py-obj docutils literal"><span class="pre">concatenate</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-46">沿现有轴连接数组序列。</span></dd>
<dt><span class="yiyi-st" id="yiyi-47"><a class="reference internal" href="numpy.stack.html#numpy.stack" title="numpy.stack"><code class="xref py py-obj docutils literal"><span class="pre">stack</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-48">沿着新轴连接数组的序列。</span></dd>
<dt><span class="yiyi-st" id="yiyi-49"><a class="reference internal" href="numpy.hstack.html#numpy.hstack" title="numpy.hstack"><code class="xref py py-obj docutils literal"><span class="pre">hstack</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-50">水平（按列顺序）堆叠数组。</span></dd>
<dt><span class="yiyi-st" id="yiyi-51"><a class="reference internal" href="numpy.vstack.html#numpy.vstack" title="numpy.vstack"><code class="xref py py-obj docutils literal"><span class="pre">vstack</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-52">垂直（按行）顺序堆叠数组。</span></dd>
<dt><span class="yiyi-st" id="yiyi-53"><a class="reference internal" href="numpy.dstack.html#numpy.dstack" title="numpy.dstack"><code class="xref py py-obj docutils literal"><span class="pre">dstack</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-54">按照深度顺序（沿第三维）堆叠数组。</span></dd>
</dl>
</div>
<p class="rubric"><span class="yiyi-st" id="yiyi-55">例子</span></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mf">9.0</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="go">[array([ 0.,  1.,  2.]), array([ 3.,  4.,  5.]), array([ 6.,  7.,  8.])]</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mf">8.0</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">10</span><span class="p">])</span>
<span class="go">[array([ 0.,  1.,  2.]),</span>
<span class="go"> array([ 3.,  4.]),</span>
<span class="go"> array([ 5.]),</span>
<span class="go"> array([ 6.,  7.]),</span>
<span class="go"> array([], dtype=float64)]</span>
</pre></div>
</div>
</dd></dl>
